package com.lishe.lishe.lishe.module.auth.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.TextView;

import com.lishe.lishe.R;

/**
 * Created by zhcase on 2017/9/5.
 */

public class UserProtocolFragment extends AuthBaseFragment implements View.OnClickListener {

    public static final String TAG = UserProtocolFragment.class.getSimpleName();

    ViewPager viewPager = null;

    private WebView mWebView;


    public UserProtocolFragment() {
    }

    public static UserProtocolFragment newInstance(){
        UserProtocolFragment instance = new UserProtocolFragment();
        Bundle bundle = new Bundle();
        instance.setArguments(bundle);
        return instance;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View containerFragment = inflater.inflate(R.layout.activity_auth_user_protocol, container, false);

        TextView nav_title_text = (TextView) containerFragment.findViewById(R.id.nav_title_text);
        nav_title_text.setText("使用协议");

        Button back = (Button) containerFragment.findViewById(R.id.nav_left_button);
        back.setOnClickListener(this);


        mWebView = (WebView) containerFragment.findViewById(R.id.user_protocal_container);

        mWebView.getSettings().setJavaScriptEnabled(false);
        mWebView.getSettings().setSupportZoom(false);
        mWebView.getSettings().setBuiltInZoomControls(false);
        mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        //mWebView.getSettings().setDefaultFontSize(18);

        //mWebView.loadDataWithBaseURL("file:///android_asset/html/user_protocol.html",);
        mWebView.loadUrl("file:///android_asset/html/user_protocol.html");

        return containerFragment;
    }

    @Override
    public void onClick(View view) {

        if (view.getId() == R.id.nav_left_button) {
//            if (viewPager != null) {
//                viewPager.setCurrentItem(FragmentAuthContants.TAB_INDEX_Login, true);
//            }

            if (mJumper != null) {
                mJumper.jumpToFragmentBack(FragmentAuthContants.TAB_INDEX_Reg);
            }else{
                getActivity().getSupportFragmentManager().popBackStack();
            }

        }
    }




}
